import { WeaSearchGroup,WeaFormItem } from 'ecCom';
import { inject, observer} from 'mobx-react';
import {WeaSwitch} from 'comsMobx';
import * as mobx from 'mobx'

/**
 * 通用高级搜索form专用  杜绝在此组件加联动
 * pros 一律 ={
 *  searchCondition,
 *  searchForm
 * }
 */
@observer
export default class FnaSearchCondition extends React.Component{
	
	render(){
		const { searchCondition,searchForm ,labelCol,wrapperCol} = this.props;		       	       		       	       
        let isFormInit = searchForm.isFormInit;
        let group = [];
        isFormInit && searchCondition.map((c,index) =>{
            let items = [];
            c.items.map((fields, idx) => {  
                items.push({
                    com:(<WeaFormItem
                        ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@${fields.domkey[0]}`}
                        label={`${fields.label}`}
                        labelCol={{span: labelCol?`${labelCol}`:`${fields.labelcol}`}}
                        error={searchForm.getError(fields)}
                        tipPosition="bottom"
                        wrapperCol={{span: wrapperCol?`${wrapperCol}`:`${fields.fieldcol}`}}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@${fields.domkey[0]}`} fieldConfig={fields} form={searchForm} onChange={this.onChange} />  
                        </WeaFormItem>),
                    colSpan:1,
                })
            });

            group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@${index}`} needTigger={true} showGroup={c.defaultshow} items={items}  col={2}/>)
        });

        return <div>{group}</div>;
	}

    onChange = (value) => {
        
    }
}